<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="com.aiflow.bean.FrontUser"%>
<html>
<head>
	<%
		String baseUrl = request.getContextPath();
	    FrontUser use = (FrontUser)session.getAttribute("user"); 
	%>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<script type="text/javascript">
	    //这里的全局是为了修改之后的刷新
		$(document).ready(function(){
		    var phonepayFrom = new Ext.form.FormPanel({
	        labelAlign: 'right',
	        renderTo: 'phonepayFromDiv',
	        bodyStyle:'padding:5px 5px 0',
	        //labelWidth: 60,
	        title: '注：网速慢会影响您的语音效果...',
	        frame:true,
	        width: 500,
	        items: [
	        { //行1
	            layout:'column',
	            items: [//共有2列
	            { columnWidth: .5, layout: 'form', items: [{ id:'num',xtype: 'textfield', fieldLabel: '缴费号码',anchor:'95%',validator:function(){
			                var va = Ext.getCmp("num").getValue();
			                Ext.Ajax.request({
	                        url:  '${pageContext.request.contextPath}/findNum.action',
		                    params:{num:va},
		                    success: function(res){
		                      var respText = Ext.util.JSON.decode(res.responseText);
		                      if(respText.datas != ''){
		                        Ext.getCmp('numVest').setText(respText.datas[0].region+' '+respText.datas[0].type);
		                      }
			                }
			                })
			                } }] },
	            { columnWidth: .5, layout: 'form', items: [new Ext.Button({id: 'search-balance-button',text: '查看余额'})] }
	            ]
	        },
	        {
	            layout:'column',
	            items: [//共有1列
	            { columnWidth: .5, layout: 'form', items: [{ id: 'balance',name:'balance',cls:'balanceC', xtype: 'label',text:'',  fieldLabel: '当前余额',anchor:'95%' }] }
	            ]
	        },
	        { //行3
	            layout: 'column',
	            items: [//共有1列
	            { columnWidth: .5, layout: 'form', items: [{id:'numVest', xtype: 'label', name: 'numTrack',cls:'balanceC',text:'', fieldLabel: '号码归属',anchor:'95%'}] }
	            ]
	        },
	        {//行4
	            layout: 'column',
	            items: [//共有1列
	            { columnWidth: .5, layout: 'form', items: [{ xtype: 'textfield', fieldLabel: '交易密码',anchor:'95%'}] }
	            ]
	        }
	        ],
		        buttons: [{
		            id: 'prepaid-recharge-button',
		            text: '缴费'
		        },{
		            text: '重置'
		        },{
		            text: '打印'
		        },{
		            text: '历史记录'
		        }]
		    });
		    
		    $("#prepaid-recharge-button").click(function(){
		          var num = Ext.getCmp("num").getValue();
                  // 发送请求
				  Anynote.ajaxRequest({
				  baseUrl: '<%=baseUrl %>',
				  baseParams: {num:num,frontUserid:'<%=use.getId()%>',clerkid:'<%=use.getVest_clerk_id()%>'},
				  action: '${pageContext.request.contextPath}/prepaid.action',
				  callback: function(jsonResult){
				  customListGrid.getStore().reload();
				  },
				  showWaiting: true,
				  failureMsg: '保存失败.'
				  })
		    });
		    
		    $("#search-balance-button").click(function(){
		          var num = Ext.getCmp("num").getValue();
                  // 发送请求
				  Anynote.ajaxRequest({
				  baseUrl: '<%=baseUrl %>',
				  baseParams: {num:num},
				  action: '${pageContext.request.contextPath}/balanceQuery.action',
				  callback: function(jsonResult){
				      Ext.getCmp('balance').setText(jsonResult.datas.balance);
				  },
				  showWaiting: true,
				  failureMsg: '保存失败.'
				  })	    
		    });
});

	</script>
</head>
<body>
<div id="phonepayDiv">
	<div id="phonepayFromDiv" style="width:100%;height:100%;"></div>
</div>
</body>
</html>
